package view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.WindowConstants;

import view.interfaces.IHome;
import controller.ControllerHome;

public class Home extends JFrame implements IHome {

    private static final long serialVersionUID = 1L;
    private ControllerHome thisController;
    public static JTabbedPane ongletsDeNavigation;
    private JLabel titreApplication;
    private JButton btnAddShapeOne, btnAddShapeTwo, btnAddShapeThree, btnNew, btnOpen, btnSave;
    public JPanel panelContentShapes;
    
    private Font policePersonnaliseeTitreApplication;
    public static JFrame jFrame;
    
    private static JPanel panneauTitreApplication;

    public Home(ControllerHome controller) {
            
        super("Ma fenetre principale");
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        thisController = controller;
        thisController.setView(this);

        jFrame = new JFrame();
        jFrame.getContentPane().setLayout(new GridLayout(2,1));
        
        panneauTitreApplication = new JPanel(new FlowLayout());
        
        btnNew = new JButton("Nouveau");
        btnNew.addActionListener(thisController);
        btnNew.setActionCommand("NEWFILE");
        
        btnOpen = new JButton("Ouvrir");
        btnOpen.addActionListener(thisController);
        btnOpen.setActionCommand("OPENFILE");
        
        btnSave = new JButton("Sauvegarder");
        btnSave.addActionListener(thisController);
        btnSave.setActionCommand("SAVEFILE");
        
        titreApplication = new JLabel("Gestionnaire de formes", JLabel.CENTER);
        policePersonnaliseeTitreApplication = new Font("Arial", Font.BOLD,20);
        titreApplication.setFont(policePersonnaliseeTitreApplication);
        
        btnAddShapeOne = new JButton("+");
        btnAddShapeOne.addActionListener(thisController);
        btnAddShapeOne.setActionCommand("ADDSHAPEONE");
        
        btnAddShapeTwo = new JButton("+");
        btnAddShapeTwo.addActionListener(thisController);
        btnAddShapeTwo.setActionCommand("ADDSHAPETWO");
        
        btnAddShapeThree = new JButton("+");
        btnAddShapeThree.addActionListener(thisController);
        btnAddShapeThree.setActionCommand("ADDSHAPETHREE");

        
        panneauTitreApplication.add(btnNew);
        panneauTitreApplication.add(btnOpen);
        panneauTitreApplication.add(btnSave);
        
        panneauTitreApplication.add(titreApplication);

        panneauTitreApplication.add(btnAddShapeOne);
        panneauTitreApplication.add(btnAddShapeTwo);
        panneauTitreApplication.add(btnAddShapeThree);
        
        this.add(panneauTitreApplication, BorderLayout.NORTH);
        
        panelContentShapes = new JPanel();
        panelContentShapes.setBackground(Color.WHITE);
        
        ViewShapes panneauDessin = new ViewShapes(thisController.getControllerViewShapes());

        panelContentShapes.add(panneauDessin, BorderLayout.CENTER);
        
        add(panelContentShapes, BorderLayout.CENTER);
        
        setSize(1000,600);

        setVisible(true);
        
    }
       
}
